#include <stdio.h>
#include<string.h>
//#include<stdlib.h>
//#include <ctype.h>
#include "stdafx.h"
#include <iostream>
using namespace std;

///---------------------------------------------------------
class Quest {
public://member functions
	Quest(); //constructor
	Quest(const char*  str1); //constructor
	Quest(const char* str1, const char* str2); //constructor
	Quest(const char* str1, const char* str2,const char* str3); //constructor
	Quest(const char* str1, const char* str2, const char* str3,const char* str4); //constructor
	Quest (const Quest& q); //copy constructor
	const Quest& operator=(Quest& q);

	~Quest(); //destructor

	ostream &operator<<(ostream& os, const Quest& q);

	void setDrink(const char* dr);
	void setFirstPortion(const char* portion);
	void setSecondPortion(const char* portion);
	void setDesert(const char* des);

	const char* getDrink() const;
	const char* getFirstPortion() const;
	const char* getSecondPortion() const;
	const char* getDesert() const;

	void deleteDrink();
	void deleteFirstPortion();
	void deleteSecondPortion();
	void deleteDesert();

	

	//ostream &operator<< (ostream& os, const Quest& p);


private: //data members

	char* drink;
	char* first_portion;
	char* second_portion;
	char*  desert;
};

// every free must be changed by delete
// change CreateForm() func.


//---------------------------------------------------
//contructors
Quest::Quest(){
	drink=first_portion=second_portion=desert=0;
}
char* createForm(char* str){
    char* tmp=(char*)malloc(strlen(str)+1);
	strcpy(tmp, str);
	return tmp;
}
Quest::Quest(const char*str1){
	drink=createForm((char*) str1);
	first_portion=second_portion=desert=0;
}
Quest::Quest(const char*str1, const char* str2){
	drink=createForm((char*) str1);
	first_portion=createForm((char*) str2);
	second_portion=desert=0;
}
Quest::Quest(const char*str1, const char* str2,const char* str3){
	drink=createForm((char*) str1);
	first_portion=createForm((char*) str2);
	second_portion=createForm((char*) str3);
	desert=0;
}
Quest::Quest(const char* str1, const char* str2, const char* str3, const char* str4){
	drink=createForm((char*) str1);
	first_portion=createForm((char*) str2);
	second_portion=createForm((char*) str3);
	desert=createForm((char*) str4);
}

Quest::Quest(const Quest& q) {
	drink=createForm((char*) q.getDrink());
	first_portion=createForm((char*) q.getFirstPortion());
	second_portion=createForm((char*) q.getSecondPortion());
	desert=createForm((char*) q.getDesert());
}

const Quest& Quest::operator=(Quest& q){
	if (this !=&q){
	free(drink);
	free(first_portion);
	free(second_portion);
	free(desert);
	drink=createForm((char*) q.getDrink());
	first_portion=createForm((char*) q.getFirstPortion());
	second_portion=createForm((char*) q.getSecondPortion());
	desert=createForm((char*) q.getDesert());
	}
	return *this;
}

//destructor
Quest:: ~Quest(){
	free(drink);
	free(first_portion);
	free(second_portion);
	free(desert);
}

Quest::ostream &operator<<(ostream& os, const Quest& q){
	return os   <<"Drink " <<q.getDrink()
				<<"FirstPortion " <<q.getFirstPortion()
				<<"SecondPortion " <<q.getSecondPortion()
				<<"Desert " <<q.getDesert();
}

//set functions
void Quest::setDrink(const char* dr){
	free(drink);
	drink=createForm((char*)dr);
}
void Quest::setFirstPortion(const char* portion){
	free(first_portion);
	first_portion=createForm((char*)portion);
}

void Quest::setSecondPortion(const char* portion){
	free(second_portion);
	second_portion=createForm((char*)portion);
}
void Quest::setDesert(const char* des){
	free(desert);
	desert=createForm((char*)des);
}

//get functions
const char* Quest::getDrink() const{
	return drink;
}
const char* Quest::getFirstPortion() const{
	return first_portion;
}
const char* Quest::getSecondPortion() const{
	return second_portion;
}
const char* Quest::getDesert() const{
	return desert;
}

//delete functions

void Quest::deleteDrink(){
	free(drink);
}
void Quest::deleteFirstPortion(){
	free(first_portion);
}
void Quest::deleteSecondPortion(){
	free(second_portion);
}
void Quest::deleteDesert(){
	free(desert);
}

